package com.ctrip.ec.biz.dao.sms;
import com.ctrip.ec.dal.DaoBase;
import com.ctrip.ec.biz.entity.sms.SmsLoginEntity;
import com.ctrip.ec.dal.DbAccess;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
public class SmsLoginDao extends DaoBase<SmsLoginEntity> {
    public SmsLoginDao() {
        super(SmsLoginEntity.class);
    }
    public SmsLoginDao(DbAccess db) {
        super(SmsLoginEntity.class,db);
    }

    public SmsLoginEntity entityByMobile(String mobile) throws SQLException {
        String sql = "select * from " + this.getTableName() + " where mobile=? order by id desc limit 1";
        List<SmsLoginEntity> list = this.db.query(SmsLoginEntity.class,sql,mobile);
        if(list.size()>0){
            return list.get(0);
        }else{
            return null;
        }
    }
}
